package com.ctrip.payment.domain;

import com.ctrip.payment.domain.base.BaseJpaEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name="task")
public class Task extends BaseJpaEntity implements Serializable {

    @NotEmpty
    @Column(name="name", length = 255)
    @ApiModelProperty("任务名称")
    private String name;

    @Column(name="date")
    @JsonFormat(timezone = "GMT+08", pattern = "yyyy-MM-dd HH:mm:ss") // 返回格式化的字符串
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 接收格式化的字符串，转为Date类型对象
    @ApiModelProperty("所属日期")
    private Date date;

    @Column(name="content", length = 2000)
    @ApiModelProperty("具体内容")
    private String content;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Task() {
    }

    public Task(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("name", name)
                .append("date", date)
                .append("content", content)
                .toString();
    }
}
